<!DOCTYPE html>
<html>
<head>
  <title><%= content_for?(:title) ? yield(:title) : 'Catlog' %></title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
  <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
  <link href='http://fonts.useso.com/css?family=Source+Sans+Pro' rel='stylesheet'>
  <%= csrf_meta_tags %>
</head>
<body>

<div class="app-navbar">
  <div class="container">
    <div class="logo grid-20">
      <%= link_to 'Catlog', root_path %>
    </div>
    <ul class="nav clearfix grid-80">
      <% JSON.parse(Setting.cache.fetch 'page_links', '{}').each do |title, link| %>
          <%= content_tag :li, link_to(title, link), class: link == request.path ? 'active' : '' %>
      <% end %>
    </ul>
  </div>
</div>

<div class="app-banner">
  <div class="container">
    <div class="info grid-50 push-25">
      <h2><%= Setting.cache.fetch 'website_title' %></h2>
    </div>
  </div>
</div>

<div class="app-middle-bar">
  <div class="container">
    <div class="grid-100">
      <ul class="nav">
        <% Category.all.each do |category| %>
           <%= content_tag :li, link_to(category.name, categorized_posts_path(category.slug)),
                           class: action_name == 'categorized' && category.slug == params[:category_slug] ? 'active' : '' %>
        <% end %>
      </ul>
    </div>
  </div>
</div>

<div class="container">
  <div class="app-content grid-75">
    <%= yield %>
  </div>

  <div class="app-sidebar grid-25 hide-mobile">
    <div class="side-top-btns">
      <a href="#"><i class="fa fa-rss-square"></i> Feed</a>
    </div>
    <div class="side-group">
      <div class="title">博客简介</div>
      <div class="content">
        <%= Setting.cache.fetch 'website_intro' %>
      </div>
    </div>

    <div class="side-group">
      <div class="title">推荐网站</div>
      <ul class="list">
        <% JSON.parse(Setting.cache.fetch 'recommend_links', '{}').each do |title, link| %>
            <li><a href="//<%= link %>" target="_blank"><%= title %></a></li>
        <% end %>
      </ul>
    </div>
  </div>
</div>

<script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', '<%= ENV['CATLOG_GA'] %>', 'auto');
    ga('send', 'pageview');

</script>

</body>
</html>
